﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

#include "GbmpDefines.h"

#include <string>

// 不能包含GcmpDevService.h
#ifdef GCMP_DEV_SERVICE_HOME
    #define GBMP_ASSERT_EXPORT DLL_EXPORT
#else
    #define GBMP_ASSERT_EXPORT DLL_IMPORT
#endif


#ifdef _WINDOWS
#include <crtdefs.h>

#undef  gbmp_assert_impl

#ifdef  __cplusplus
extern "C" {
#endif

    _CRTIMP void __cdecl _wassert(_In_z_ const wchar_t * _Message, _In_z_ const wchar_t *_File, _In_ unsigned _Line);

#ifdef  __cplusplus
}
#endif

#define gbmp_assert_impl(_Expression) (void)( (!!(_Expression)) || (_wassert(_CRT_WIDE(#_Expression), _CRT_WIDE(__FILE__), __LINE__), 0) )

#else 

#include <assert.h>
//非windows 平台
#define gbmp_assert_impl(_Expression)  assert(_Expression)

#endif


namespace gcmp
{
    GBMP_ASSERT_EXPORT bool IsAssertEnabled();
    GBMP_ASSERT_EXPORT void DumpAssertToLog(const std::string& expression, const std::string& file, int line, const std::string& function);
}